package com.example.testbank;

import java.io.Serializable;
import java.util.Vector;


import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

public class QSet extends Activity implements Serializable {
	//Identifier in SQL
	private long _defaultID;
	
	//Question Information retrieved from SQL
	private String _question;
	private Vector<String> _options;
	private String _feedback;

	private Rect _clippingRect;
	private Bitmap _image;
	
	//Return to SQL
	private String _optionArrangement;
	private int _currentAnswer;
	private Vector<Integer> _randomizedOptions;
	
	//Constructs a Question Set with an image
	public QSet(String question, Vector<String> options, Vector<Integer> arrangement, String feedback, long id, Bitmap image, Rect clippingRect) {
		//Fills the question details
		_question = question;
		_options = options;
		_feedback = feedback;
		_defaultID = id;
		_currentAnswer = 0;
		_randomizedOptions = arrangement;
		
		//Set the image
		_image = image;
		_clippingRect = clippingRect;
	}
	
	//Constructs a Question Set without an image
	public QSet(String question, Vector<String> options, Vector<Integer> arrangement, String feedback, long id) {
		_question = question;
		_options = options;
		_feedback = feedback;
		_defaultID = id;
		_image = null;
		_currentAnswer = 0;
		_randomizedOptions = arrangement;
	}
	
	public String getQuestion() {
		return _question;
	}
	
	public Vector<String> getOptions() {
		return _options;
	}
	
	public Vector<Integer> randomOptions() {
		//To random and display the options
		int size = _options.size();
		_randomizedOptions = new Vector<Integer>();
		int random = (int)Math.floor(Math.random()*size);
	
		for(int i = 0; i < size; i++) {
			_randomizedOptions.add((random+i)%size);
		}
		
		return _randomizedOptions;
	}
	
	public void setID(long id) {
		_defaultID = id;
	}
	
	public long getID() {
		return _defaultID;
	}
	
	public void chooseAnswer(int answer) {
		_currentAnswer = answer;
	}
	
	public void checkAnswer() {
		
	}
	
	public void showFeedback() {
		
	}
	
	public void exportToSQL() {
		//Do the saving of the user's answer
	}
}
